#!/bin/sh
APP_HOME="/data/app"
APP_NAME="spring-cloud-config"
APP_JAR_NAME="spring-cloud-config-1.0-SNAPSHOT.jar"
APP_JAR_PATH=$APP_HOME/$APP_NAME/$APP_JAR_NAME
WORK_PATH=$APP_HOME/$APP_NAME
TMP_PATH=$APP_HOME/tmp

# 创建文件夹
mkdir -p $WORK_PATH
mkdir -p $TMP_PATH

# 拷贝jar
cp -rf $APP_HOME/tmp/$APP_JAR_NAME $WORK_PATH

# 删除旧脚本
rm -rf $WORK_PATH/server.sh

# 生成脚本
cat $APP_HOME/script/server.head.sh >> $WORK_PATH/server.sh
echo "SERVER_NAME=$APP_NAME" >> $WORK_PATH/server.sh
echo "$SERVER_JAR_NAME=$APP_JAR_NAME" >> $WORK_PATH/server.sh
cat $APP_HOME/script/server.tail.sh >> $WORK_PATH/server.sh

# 启动服务
cd $WORK_PATH
chmod +x server.sh
sh server.sh restart